<?php

namespace App\Http\Controllers;

use App\Models\Area;
use App\Models\Car;
use App\Models\Complaint;
use App\Models\Cts;
use App\Models\Flow;
use App\Models\Gps;
use App\Models\GpsHistory;
use App\Models\Guide;
use App\Models\Hotel;
use App\Models\Notice;
use App\Models\Rural;
use App\Models\Scene;
use App\Models\Team;
use Carbon\Carbon;
use DB;

class GpsController extends AuthController
{

    public function index(){
        $list = Gps::all();
        foreach ($list as $val){
            $val->VEHICLE_COLOR = config('options.vehicle_color')[$val->VEHICLE_COLOR];
            $val->ALARM = strpos($val->ALARM,'1')?true:false;
            //$val->teams = DB::table('team_count')->where('car_id','like','%'.$val->VEHICLE_NO.'%')->where('arrive_date',Carbon::today()->toDateString())->get(['travel_agency','count','guide','origin','destination']);
        }
        return response()->json($list);
    }
    public function history(){
        return response()->json(GpsHistory::all());
    }

}
